home *** CD-ROM | disk | FTP | other *** search
/ Champak 74 / Volume 74 My Disc - Damaged.iso / Games / shusher.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2008-08-08  |  8.3 KB  |  345 lines

  1. function levelUp()
  2. {
  3.    level++;
  4.    if(filledSeats + 2 <= numberOfSeats - 1)
  5.    {
  6.       filledSeats += 2;
  7.    }
  8.    if(noiseFrequency > 50)
  9.    {
  10.       noiseFrequency -= 20;
  11.    }
  12. }
  13. function clearScreen()
  14. {
  15.    removeMovieClip("Game");
  16.    removeMovieClip("Flashlight");
  17.    removeMovieClip("Interface");
  18. }
  19. function quietNoisyPeople()
  20. {
  21.    var _loc2_ = 0;
  22.    while(_loc2_ <= noisyPeople.length - 1)
  23.    {
  24.       thePerson = _root.Game["Seat" + noisyPeople[_loc2_]];
  25.       noisyPeople.splice(_loc2_,1);
  26.       thePerson.gotoAndStop("Ready");
  27.       thePerson.makingNoise = false;
  28.       _loc2_ = _loc2_ + 1;
  29.    }
  30. }
  31. function unleashNoise()
  32. {
  33.    do
  34.    {
  35.       var match = false;
  36.       var _loc2_ = randInt(0,peopleSeated.length - 1);
  37.       thePerson = _root.Game["Seat" + peopleSeated[_loc2_]];
  38.       if(thePerson.makingNoise)
  39.       {
  40.          match = true;
  41.       }
  42.    }
  43.    while(match == true);
  44.    
  45.    noisyPeople.push(peopleSeated[_loc2_]);
  46.    thePerson.gotoAndStop("MakingNoise");
  47.    thePerson.makingNoise = true;
  48.    if(!lightsOn)
  49.    {
  50.       attachMovie("noisecue","NoiseCue" + peopleSeated[_loc2_],getNextHighestDepth());
  51.       theNoiseCue = _root["NoiseCue" + peopleSeated[_loc2_]];
  52.       theNoiseCue._x = thePerson._x;
  53.       theNoiseCue._y = thePerson._y + 20;
  54.    }
  55. }
  56. function shush()
  57. {
  58.    SFX.gotoAndPlay("Shush");
  59.    Game.Player.Clip.gotoAndPlay("Shush");
  60.    var _loc3_ = 0;
  61.    while(_loc3_ <= noisyPeople.length - 1)
  62.    {
  63.       thePerson = _root.Game["Seat" + noisyPeople[_loc3_]];
  64.       if(Game.Player.Clip.Collider.hitTest(thePerson))
  65.       {
  66.          var _loc4_ = 0;
  67.          var _loc2_ = 0;
  68.          while(_loc2_ <= noisyPeople.length - 1)
  69.          {
  70.             otherPerson = _root.Game["Seat" + noisyPeople[_loc2_]];
  71.             if(otherPerson.myType == thePerson.myType)
  72.             {
  73.                _loc4_ = _loc4_ + 1;
  74.             }
  75.             _loc2_ = _loc2_ + 1;
  76.          }
  77.          if(_loc4_ <= 1)
  78.          {
  79.             if(thePerson.myType == 1)
  80.             {
  81.                SFX.gotoAndPlay("StopPhony");
  82.             }
  83.             else if(thePerson.myType == 2)
  84.             {
  85.                SFX.gotoAndPlay("StopCrybaby");
  86.             }
  87.             else if(thePerson.myType == 3)
  88.             {
  89.                SFX.gotoAndPlay("StopSnorer");
  90.             }
  91.             else if(thePerson.myType == 4)
  92.             {
  93.                SFX.gotoAndPlay("StopGobbler");
  94.             }
  95.             else if(thePerson.myType == 5)
  96.             {
  97.                SFX.gotoAndPlay("StopLaugher");
  98.             }
  99.          }
  100.          noisyPeople.splice(_loc3_,1);
  101.          score += shushPointValue;
  102.          thePerson.gotoAndStop("Ready");
  103.          thePerson.makingNoise = false;
  104.          break;
  105.       }
  106.       _loc3_ = _loc3_ + 1;
  107.    }
  108. }
  109. function setupTheatre()
  110. {
  111.    _root.createEmptyMovieClip("Game",1);
  112.    Game._x = 0;
  113.    Game._y = 20;
  114.    Game.attachMovie("player","Player",50);
  115.    var _loc5_ = new Array();
  116.    var _loc7_ = numberOfSeats - filledSeats;
  117.    var _loc2_ = 1;
  118.    while(_loc2_ < _loc7_)
  119.    {
  120.       _loc5_.push(0);
  121.       _loc2_ = _loc2_ + 1;
  122.    }
  123.    _loc2_ = 1;
  124.    while(_loc2_ <= filledSeats)
  125.    {
  126.       _loc5_.push(randInt(1,5));
  127.       _loc2_ = _loc2_ + 1;
  128.    }
  129.    shuffle(_loc5_);
  130.    _loc5_.splice(forceEmptySeat - 1,0,0);
  131.    _loc5_.splice(0,0,0);
  132.    peopleSeated = new Array();
  133.    _loc2_ = 1;
  134.    var _loc4_ = 1;
  135.    while(_loc4_ <= 7)
  136.    {
  137.       var _loc6_ = _root["mazeRow" + _loc4_];
  138.       var _loc3_ = 1;
  139.       while(_loc3_ <= 11)
  140.       {
  141.          if(_loc6_[_loc3_ - 1] == 1)
  142.          {
  143.             Game.attachMovie("seat" + _loc5_[_loc2_],"Seat" + _loc2_,(_loc4_ - 1) * 100 + _loc3_);
  144.             theSeat = Game["Seat" + _loc2_];
  145.             theSeat._x = (_loc3_ - 1) * tileWidth;
  146.             theSeat._y = (_loc4_ - 1) * tileHeight;
  147.             theSeat.myType = _loc5_[_loc2_];
  148.             theSeat.makingNoise = false;
  149.             if(_loc5_[_loc2_] > 0)
  150.             {
  151.                _root.peopleSeated.push(_loc2_);
  152.             }
  153.             _loc2_ = _loc2_ + 1;
  154.          }
  155.          _loc3_ = _loc3_ + 1;
  156.       }
  157.       _loc4_ = _loc4_ + 1;
  158.    }
  159. }
  160. function moveAvatar(theClip, theDir)
  161. {
  162.    theClip.gotoAndStop(theDir);
  163.    var _loc4_ = theClip._x;
  164.    var _loc3_ = theClip._y;
  165.    if(theDir == "up")
  166.    {
  167.       _loc3_ = theClip._y - theClip.moveSpeed;
  168.    }
  169.    else if(theDir == "down")
  170.    {
  171.       _loc3_ = theClip._y + theClip.moveSpeed;
  172.    }
  173.    else if(theDir == "left")
  174.    {
  175.       _loc4_ = theClip._x - theClip.moveSpeed;
  176.    }
  177.    else if(theDir == "right")
  178.    {
  179.       _loc4_ = theClip._x + theClip.moveSpeed;
  180.    }
  181.    if(!checkMazeHit(_loc4_,_loc3_,theDir))
  182.    {
  183.       if(theDir == "up")
  184.       {
  185.          theClip._x = theClip.currentColumn * tileWidth - avatarRadius;
  186.          theClip._y = _loc3_;
  187.       }
  188.       else if(theDir == "down")
  189.       {
  190.          theClip._x = theClip.currentColumn * tileWidth - avatarRadius;
  191.          theClip._y = _loc3_;
  192.       }
  193.       else if(theDir == "left")
  194.       {
  195.          theClip._x = _loc4_;
  196.          theClip._y = theClip.currentRow * tileHeight - avatarRadius;
  197.       }
  198.       else if(theDir == "right")
  199.       {
  200.          theClip._x = _loc4_;
  201.          theClip._y = theClip.currentRow * tileHeight - avatarRadius;
  202.       }
  203.       theClip.moveDir = theDir;
  204.    }
  205.    else
  206.    {
  207.       if(theDir == "up")
  208.       {
  209.          theClip._y = theClip.currentRow * tileHeight - avatarRadius;
  210.       }
  211.       else if(theDir == "down")
  212.       {
  213.          theClip._y = theClip.currentRow * tileHeight - avatarRadius;
  214.       }
  215.       else if(theDir == "left")
  216.       {
  217.          theClip._x = theClip.currentColumn * tileWidth - avatarRadius;
  218.       }
  219.       else if(theDir == "right")
  220.       {
  221.          theClip._x = theClip.currentColumn * tileWidth - avatarRadius;
  222.       }
  223.       theClip.moveDir = null;
  224.    }
  225.    Flashlight._x = theClip._x;
  226.    Flashlight._y = theClip._y;
  227. }
  228. function checkMazeHit(destX, destY, theDir)
  229. {
  230.    var _loc4_ = destX;
  231.    var _loc3_ = destY;
  232.    if(theDir == "up")
  233.    {
  234.       _loc3_ = destY - avatarRadius;
  235.    }
  236.    else if(theDir == "down")
  237.    {
  238.       _loc3_ = destY + avatarRadius;
  239.    }
  240.    else if(theDir == "left")
  241.    {
  242.       _loc4_ = destX - avatarRadius;
  243.    }
  244.    else if(theDir == "right")
  245.    {
  246.       _loc4_ = destX + avatarRadius;
  247.    }
  248.    var _loc5_ = Math.ceil(_loc3_ / tileHeight);
  249.    var _loc2_ = Math.ceil(_loc4_ / tileWidth);
  250.    if(_loc5_ > 0 && _loc5_ <= mazeHeight)
  251.    {
  252.       if(_loc2_ > 0 && _loc2_ <= mazeWidth)
  253.       {
  254.          if(_root["mazeRow" + _loc5_][_loc2_ - 1] == 1)
  255.          {
  256.             return true;
  257.          }
  258.          return false;
  259.       }
  260.       return true;
  261.    }
  262.    return true;
  263. }
  264. function decrementTimer()
  265. {
  266.    if(secondsLeft == 0)
  267.    {
  268.       if(minutesLeft == 0)
  269.       {
  270.          clearInterval(timerCode);
  271.          gotoAndStop("WinLevel");
  272.          play();
  273.       }
  274.       else
  275.       {
  276.          secondsLeft = 59;
  277.          minutesLeft--;
  278.       }
  279.    }
  280.    else
  281.    {
  282.       secondsLeft--;
  283.    }
  284. }
  285. function setTimerDigits(theMins, theSecs, theClip)
  286. {
  287.    minutesText = String(theMins);
  288.    secondsText = String(theSecs);
  289.    if(minutesText.length < 2)
  290.    {
  291.       theClip.mins1 = "";
  292.       theClip.mins2 = minutesText;
  293.    }
  294.    else
  295.    {
  296.       theClip.mins1 = minutesText.substr(0,1);
  297.       theClip.mins2 = minutesText.substr(1,1);
  298.    }
  299.    if(secondsText.length < 2)
  300.    {
  301.       theClip.secs1 = "0";
  302.       theClip.secs2 = secondsText;
  303.    }
  304.    else
  305.    {
  306.       theClip.secs1 = secondsText.substr(0,1);
  307.       theClip.secs2 = secondsText.substr(1,1);
  308.    }
  309.    if(theMins < 10)
  310.    {
  311.       theClip.gotoAndStop("FreakOut");
  312.    }
  313.    else
  314.    {
  315.       theClip.gotoAndStop("Normal");
  316.    }
  317. }
  318. function randInt(num0, num1)
  319. {
  320.    if(arguments.length == 1)
  321.    {
  322.       return Math.round(Math.random() * num0);
  323.    }
  324.    return Math.round(Math.random() * Math.abs(num0 - num1)) + num0;
  325. }
  326. function shuffle(theArray)
  327. {
  328.    i = 0;
  329.    while(i < theArray.length - 1)
  330.    {
  331.       var _loc2_ = Math.round(Math.random() * i);
  332.       var _loc3_ = theArray[i];
  333.       theArray[i] = theArray[_loc2_];
  334.       theArray[_loc2_] = _loc3_;
  335.       i++;
  336.    }
  337.    return theArray;
  338. }
  339. stop();
  340. fscommand("allowscale",false);
  341. funcHITBOX = function(arEvent, arAction)
  342. {
  343.    getURL("javascript: _hbLink (\'/flash/" + arEvent + "/" + arAction + "ΓÇÖ)","");
  344. };
  345.